import java.io.FileReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Properties;

public class Testtest {
    public static void main(String[] args) throws Exception{
        Properties properties = new Properties();
        properties.load(new FileReader("C:\\Users\\星星在唱歌\\Desktop\\学习\\LIU\\day23\\a.properties"));
        String className = properties.getProperty("className");
        Class<?> aClass = Class.forName(className);

        //创建实例对象
        Object o = aClass.newInstance();
        //获取所有的属性
        Field[] d1 = aClass.getDeclaredFields();
        System.out.println("所有的属性" +Arrays.toString(d1));

        //获取name
        Field fileTwo = aClass.getDeclaredField(properties.getProperty("fileTwo"));
        fileTwo.setAccessible(true);
        //赋值
        fileTwo.set(o, properties.getProperty("valueTwo"));
        //打印
        Object value1 = fileTwo.get(o);
        System.out.println(value1);

        //获取所有的方法
        Method[] d2 = aClass.getDeclaredMethods();
        System.out.println("所有的方法" + Arrays.toString(d2));
        //获取一个方法
        Method m1 = aClass.getDeclaredMethod(properties.getProperty("method1"),int.class,double.class);
        m1.setAccessible(true);
        Object invoke = m1.invoke(o, 100, 20);
        System.out.println("返回值：" + invoke);
    }
}
